<?php

namespace App\Modules\LuckDraw\Models;

use Illuminate\Database\Eloquent\Model;

class CompensateLogModel extends Model {
    protected $table = "luck_draw_compensate_log";

    public static function log(int $userId, int $luckId, int $pool, int $awardId, int $type, int $timeLimit, int $price, int $status = 1): ?CompensateLogModel {
        $compensateLogModel = new CompensateLogModel();
        $compensateLogModel->user_id = $userId;
        $compensateLogModel->luck_id = $luckId;
        $compensateLogModel->pool = $pool;
        $compensateLogModel->award_id = $awardId;
        $compensateLogModel->type = $type;
        $compensateLogModel->time_limit = $timeLimit;
        $compensateLogModel->price = $price;
        $compensateLogModel->status = $status;
        $ok = $compensateLogModel->save();
        return $ok?$compensateLogModel:null;
    }

}